<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>select</title>
</head>
<body>
	<select id="sheng"></select>
	<select id="shi"><option>请选择</option></select>
</body>
<script type="text/javascript">
	var data=[];
	data[0] = {name:"陕西省",city:["西安市","宝鸡市","汉中市"]};
	data[1] = {name:"河南省",city:["郑州市","驻马店","焦作市"]};
	window.onload= function(){
		var sheng = document.getElementById("sheng");
		var shi = document.getElementById("shi");
		console.log(sheng);
		sheng.options[0] = new Option("请选择","");
		for(var i=0;i<data.length;i++){
			sheng.options[i+1] = new Option(data[i].name,data[i].name);
		}
		sheng.onchange = function(){
			var index = this.selectedIndex;
			console.log(index);
			shi.options.length = 0;
			var city = data[index-1].city;
			for(var i=0;i<city.length;i++){
				shi.options[i] = new Option(city[i],city[i]);
				shi.focus();
			}
		}
	}

</script>
</html>